<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>双随机事项管理管理</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
	
		$(document).ready(function() {
			 <c:if test="${empty drSx.id}">
			 $('#sxMc').val('${fns:getUser().getOffice().name}-天津局日常施检工作事项');
			 </c:if>
			var sx = '${drSx.sxFdsx}';
			$('.select-no').hide();
			var copyThisA_ = $("#"+sx).clone();
			if ($("#selectA").length > 0) {
				$("#selectA a").html($(this).text());
			} else {
				$(".select-result dl").append(copyThisA_.attr("id", "selectA"));
			}
			
//			var zy = '${drSx.sxZy}';
//			var zy_arr = zy.split(",");
//			for(var i=0;i<zy_arr.length;i++){ 
//				var type = zy_arr[i];
//				var copyThisB = $("[date-type="+type+"]").clone();
//				if ($("[date-type="+type+"]").hasClass("selected_")) {
//					$(".select-result_ li[date-type='" + type + "']").remove();
//				} else {
//					$(".select-result_ ul").append(copyThisB);
//				};
//				$("[date-type="+type+"]").toggleClass("selected_");				
//			}
//			$(".select-result_ ul").delegate("li","click", function(){
//				var type = $(this).attr("date-type");
//				$(this).remove();
//				$("#select2_ li[date-type='" + type + "']").removeClass("selected_");
//			});		
//			$("#select2_ li").click(function() {
//				var type = $(this).attr("date-type");
//				var copyThisB = $(this).clone();
//				if ($(this).hasClass("selected_")) {
//					$(".select-result_ li[date-type='" + type + "']").remove();
//				} else {
//					$(".select-result_ ul").append(copyThisB);
//				};
//				$(this).toggleClass("selected_");
//			});				
			//$("#name").focus();
			$("#inputForm").validate({
				submitHandler: function(form){
					loading('正在提交，请稍等...');
					form.submit();
				},
				errorContainer: "#messageBox",
				errorPlacement: function(error, element) {
					$("#messageBox").text("输入有误，请先更正。");
					if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
						error.appendTo(element.parent().parent());
					} else {
						error.insertAfter(element);
					}
				}
			});
		});
		function doSubmit(){
			var str = ""; 
			$(".select-result_").find("li").each(function(){
				str = str+$(this).attr("date-type")+",";
			});
			$('#sxZy').val(str);
			$('#inputForm').submit();
		}		
	</script>
</head>
<body>
	<ul class="nav nav-tabs">
		<c:if test="${empty drSx.id}"><li><a href="${ctx}/sx/drSx/form?id=${drSx.id}">法定事项<shiro:hasPermission name="sx:drSx:edit">${not empty drSx.id?'修改':'添加'}</shiro:hasPermission><shiro:lacksPermission name="sx:drSx:edit">查看</shiro:lacksPermission></a></li></c:if>
        <c:if test="${empty drSx.id && fns:getUser().getOffice().id != '1'}"><li><a href="${ctx}/sx/drSx/zdyform_tjjsx?id=${drSx.id}">天津局事项<shiro:hasPermission name="sx:drSx:edit">${not empty drSx.id?'修改':'添加'}</shiro:hasPermission><shiro:lacksPermission name="sx:drSx:edit">查看</shiro:lacksPermission></a></li></c:if>
		<c:if test="${empty drSx.id && fns:getUser().getOffice().id!='1'}"><li class="active"><a href="${ctx}/sx/drSx/zdyform_tjj?id=${drSx.id}">天津局日常施检工作事项<shiro:hasPermission name="sx:drSx:edit">${not empty drSx.id?'修改':'添加'}</shiro:hasPermission><shiro:lacksPermission name="sx:drSx:edit">查看</shiro:lacksPermission></a></li></c:if>          
        <li><a href="${ctx}/sx/drSx/zdyform?id=${drSx.id}">${fns:getUser().getOffice().name}事项<shiro:hasPermission name="sx:drSx:edit">${not empty drSx.id?'修改':'添加'}</shiro:hasPermission><shiro:lacksPermission name="sx:drSx:edit">查看</shiro:lacksPermission></a></li>
	</ul><br/>
	<form:form id="inputForm" modelAttribute="drSx" action="${ctx}/sx/drSx/save" method="post" class="form-horizontal">
    	<input type="hidden" name="methodflag" id="methodflag" value=""/>
		<form:hidden path="id"/>
        <form:hidden path="sxZdy" value="1"/>
        <form:hidden path="sxZy" value=""/>
        <form:hidden path="sxFlag" value="03"/>
        <form:hidden path="officeZd" value="${fns:getUser().getOffice().id}"/>
		<sys:message content="${message}"/>		
		<div class="control-group">
			<label class="control-label">事项名称：</label>
			<div class="controls">
				<form:input path="sxMc" htmlEscape="false" maxlength="255" class="input-xxlarge"/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">制定部门：</label>
			<div class="controls">
				${fns:getUser().getOffice()}
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">管理部门：</label>
			<div class="controls">
				<sys:treeselect id="office_gl" name="officeGl.id" value="${drSx.officeGl.id}" labelName="officeGl.name" labelValue="${drSx.officeGl.name}"
					title="部门" url="/sys/office/treeData?type=2" cssClass="" allowClear="true" notAllowSelectParent="false"/>
			</div>
		</div>
        <!--<div class="control-group">
                    <label class="control-label">所需专业：</label>
                    <div class="controls">
                        
                        <div class="sousuo clearfix">
                            <div style="float:left;width:50px;"><font color="black">选择专业</font> </div>
                            <div class="select-result_ clearfix" style="float:right">
                                
                                <ul>
                                </ul>
                                
                            </div>
                        </div>       
                        <div class="updown_box">
                            <ul id="select2_">
                                <c:forEach items="${fns:getDictList('sys_user_zy')}" varStatus="i" var="dic">                      
                                <li date-type="${dic.value}"><a href="javascript:;">${dic.label}</a></li>                             
                                </c:forEach>                      
        
                            </ul>
                        </div>            
                        <input type="hidden" value="" id="selectposhidden" />	                                      
                    </div>
                </div>-->
		<div class="control-group">
			<label class="control-label">备注：</label>
			<div class="controls">
				<form:textarea path="sxBz" htmlEscape="false" maxlength="255" rows="4" class="input-xxlarge "/>
			</div>
		</div>
		<div class="form-actions">
			<c:if test="${empty drSx.id}"><shiro:hasPermission name="sx:drSx:edit"><input id="btnSubmit" class="btn btn-primary" type="button" value="下一步，配置执法对象库" onClick="javascript:doSubmit();"/>&nbsp;</shiro:hasPermission></c:if>
            <shiro:hasPermission name="sx:drSx:edit"><input id="btnSubmit2" class="btn btn-primary" type="button" value="保 存" onClick="javascript:$('#methodflag').val('0');doSubmit();"/>&nbsp;</shiro:hasPermission>
			<input id="btnCancel" class="btn" type="button" value="返 回" onClick="history.go(-1)"/>
		</div>
	</form:form>
</body>
</html>